#!/usr/bin/perl

# This script should be uploaded to the web server.

use warnings;
use strict;
use File::Find;
find (\&wanted, ("."));
sub wanted
{
   if (/(.*\.(?:html|css|js|txt)$)/i) {
      print "Compressing $File::Find::name\n";
      if (! -f "$_.gz") {
         system ("gzip --keep --best --force $_");
	 #make sure the compressed file has the same timestamp as the original for caching purposes
	 system ("touch -r $_ $_.gz");
      }
   }
}
